import java.util.Arrays;
import java.util.Map;

class MyArray2<T>{
    public T[] array = (T[])new Object[10];

    public T getpos(int pos) {
        return array[pos];
    }

    public void setpos(int pos, T val) {
        this.array[pos] = val;
    }

}

public class demo2 {
    public static void main(String[] args) {
        //只能传int类型数据<Integer>
        MyArray2<Integer> myarray = new MyArray2<>();
        MyArray2<String> myarray2 = new MyArray2<>();
        myarray.setpos(0,10);
        myarray2.setpos(1,"dudu");
        //不用强制类型转化了，需要什么类型我们就传什么类型--也可以是多个
        int ret = myarray.getpos(0);
        String ret2 = myarray2.getpos(1);
        System.out.println(ret);
        System.out.println(ret2);
    }
    }



